package day_2023_4_to_7;
import java.util.*;
/**
 * @author haomin
 * @date 2023/05/15 22:32
 **/
public class Day5_15_1072 {
    class Solution {
        public int maxEqualRowsAfterFlips(int[][] matrix) {
            int m = matrix.length, n = matrix[0].length, res = 0;
            Map<String, Integer> map = new HashMap<String, Integer>();
            for (int i = 0; i < m; i++) {
                char[] arr = new char[n];
                Arrays.fill(arr, '0');
                for (int j = 0; j < n; j++) {
                    // 如果 matrix[i][0] 为 1，则对该行元素进行翻转
                    arr[j] = (char) ('0' + (matrix[i][j] ^ matrix[i][0]));
                }
                String s = new String(arr);
                map.put(s, map.getOrDefault(s, 0) + 1);
                res = Math.max(res, map.getOrDefault(s, 0));
            }
            return res;
        }
    }
}